<%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2021/4/13
  Time: 13:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>

    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css">
    <script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/xadmin.js"></script>
</head>
<body onload="load()">
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>导航元素</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">

            <input type="text" name="username" placeholder="请输入用户名" autocomplete="off" class="layui-input">
            <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>
    <xblock>

        <button class="layui-btn"
                onclick="x_admin_show('添加用户','${pageContext.request.contextPath}/permission/addPermission')"><i
                class="layui-icon"></i>添加权限
        </button>
        <span class="x-right" style="line-height:40px">共有数据：<span id="countData"></span> 条</span>
    </xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>
                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i
                        class="layui-icon">&#xe605;</i></div>
            </th>
            <th>ID</th>
            <th>英文名</th>
            <th>中文名</th>
            <th>父节点</th>
            <th>类型</th>
            <th>url</th>
            <th>状态</th>
            <th>操作</th>
        </thead>
        <tbody id="tb" >


        </tbody>
    </table>
    <div class="page">
        <div>
            <a class="prev" href="">&lt;&lt;</a>

            <span class="current">1</span>

            <a class="next" href="">&gt;&gt;</a>
        </div>
    </div>

</div>
<script>


    /*用户-删除*/
    function member_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            //发异步删除数据
            $(obj).parents("tr").remove();
            layer.msg('已删除!', {icon: 1, time: 1000});
        });
    }
</script>
</body>
<script>
    function load() {
        $.ajax({
            url: "${pageContext.request.contextPath}/permission/permissionList",
            dataType: "json",
            success: function (data) {
                console.log(data);
                if (typeof (data.info) == "string") {
                    $("#tb").html("");
                } else {
                    var html = "";
                    for (var i = 0; i < data.info.length; i++) {
                        html += "<tr>" +
                            "<td>" +
                            "   <div class=\"layui-unselect layui-form-checkbox\" lay-skin=\"primary\" data-id='2'><i class=\"layui-icon\">&#xe605;</i></div>" +
                        "</td>" +
                            "<td>" + data.info[i].pId + "</td>"+
                             "<td>" + data.info[i].pName + "</td>" +
                            "<td>" + data.info[i].pNameCh + "</td>" +
                            "<td>" + data.info[i].parentId + "</td>" +
                            "<td>" + data.info[i].type + "</td>" +
                            "<td>" + data.info[i].url + "</td>" +
                            "<td>" + data.info[i].state + "</td>" +

                            "<td class='td-manage'>"+
                            "        <a title=\"编辑权限\" onclick=\"x_admin_show('修改权限','${pageContext.request.contextPath}/permission/permissionEdit')\"href=\"javascript:;\">\n" +
                            "                    <i class=\"layui-icon\">&#xe642;</i>\n" +
                            "                </a>"+
                                " <a title=\"删除权限\" onclick=\"member_del(this,'要删除的id')\" href=\"javascript:;\">\n" +
                            "                <i class=\"layui-icon\">&#xe640;</i>\n" +
                            "              </a>"+
                            "</td>"+
                        //    this指当前标签，这里就指向 button标签（写在哪个标签就是哪个标签）
                        "</tr>";
                    }
                    $("#tb").html(html);
                    $("#countData").text(data.info.length);
                }
            }
        })
    }
</script>
</html>
